Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[msbuild] Add support for bundling original resources in libraries. Fixes #19028. #20822

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

rolfbjarne
Copy link
Member

If a library references resources, until now we've pre-compile/pre-processed
some of those before embedding them the library. This applies to resources of
the following item groups:

  • AtlasTexture
  • BundleResource
  • Collada
  • CoreMLModel
  • ImageAsset
  • InterfaceDefinition
  • SceneKitAsset

However, pre-processing resources as a few problems:

  • It requires a native (Xcode) toolchain.
    • This is unfortunate when building from Windows: the current approach is
      that when building a library as a referenced project, the remoting part
      is skipped, so all such resources are just dropped.
    • It also means building on Linux doesn't work.
  • It makes it impossible to merge resources with the same name, if we wanted
    to do that.

So I'm adding support for bundling the original resources in library projects.

This is enabled using the MSBuild property BundleOriginalResources=true,
which is turned off by default for .NET 8 and turned on by default for .NET 9+.

Additionally I've added PartialAppManifest items to the list of bundled
resources from class libraries.

Fixes #19028.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne force-pushed the dev/rolf/msbuild-bundle-original-resources-in-libraries branch from e3d259c to c44b816 Compare October 28, 2024 14:38
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Use a file (as opposed to a directory) as the Outputs property in MSBuild targets.

Directories have unintuitive file stamp behavior sometimes, which may confuse incremental builds.
* Run both sets of Windows tests (local and remote), and fail afterwards if there
  are test failures. This way we get both test suites executed even if the first
  one fails.
* Create a script for executing the local tests (makes it easier to run locally
  as well).
* Make it possible to use a custom built .NET locally by honoring any DOTNET variable
  instead of blindly setting it (makes it easier to test locally).
* Add a .gitignore for the test configuration file we create to run tests on Windows.
* Some minor code simplifications.
…ixes #19028.

If a library references resources, until now we've pre-compile/pre-processed
some of those before embedding them the library. This applies to resources of
the following item groups:

* AtlasTexture
* BundleResource
* Collada
* CoreMLModel
* ImageAsset
* InterfaceDefinition
* SceneKitAsset

However, pre-processing resources as a few problems:

* It requires a native (Xcode) toolchain.
    * This is unfortunate when building from Windows: the current approach is
      that when building a library as a referenced project, the remoting part
      is skipped, so all such resources are just dropped.
    * It also means building on Linux doesn't work.
* It makes it impossible to merge resources with the same name, if we wanted
  to do that.

So I'm adding support for bundling the original resources in library projects.

This is enabled using the MSBuild property `BundleOriginalResources=true`,
which is turned off by default for .NET 8 and turned on by default for .NET 9.

Fixes #19028.
Also enable nullability and fix any issues.
The SceneKitAsset items contains all the resources within a .scnasset directory.
However, we need to pass the .scnasset directory to the native tooling, so we compute
the path to the .scnasset directory, and create a new item for it.

This new item must have the correct LogicalName set, which is accomplished by:

* Not deleting the LogicalName from the original item before using it to compute
  the new item's LogicalName.
* Compute the correct LogicalName for the .scnasset, and actually set it.

This fixes an issue where we'd be unable to detec previously processed SceneKitAsset
items in universal builds, because the files wouldn't located where they should be
on disk.
…Resources targets remotely.

They don't seem to need it.
XVS doesn't copy it when running remotely, and it's needed.
@rolfbjarne rolfbjarne force-pushed the dev/rolf/msbuild-bundle-original-resources-in-libraries branch from c44b816 to eb535b5 Compare October 31, 2024 12:53
@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: eb535b57a8e2086c6a2b0a57c0d888672fff0a00 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 1 tests failed, 28 tests passed.

Failures

❌ dotnettests tests (iOS)

1 tests failed, 0 tests passed.
  • DotNet tests: Failed (Execution failed with exit code 1)

Html Report (VSDrops) Download

Successes

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
⚠️ framework: No tests selected. Html Report (VSDrops) Download
✅ fsharp: All 1 tests passed. Html Report (VSDrops) Download
✅ generator: All 3 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 1 tests passed. Html Report (VSDrops) Download
✅ introspection: All 1 tests passed. Html Report (VSDrops) Download
✅ linker: All 10 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 7 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 1 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: eb535b57a8e2086c6a2b0a57c0d888672fff0a00 [PR build]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for bundling original assets in library projects
2 participants